feat: added compatibility notices for lazy loading#964
Conversation
There was a problem hiding this comment.
Pull Request Overview
Adds admin UI indicators and clearer conflict notices when other plugins provide overlapping lazy loading functionality. Key changes include: updated translated conflict messages for WP Rocket and Jetpack, added an admin menu badge showing the number of active conflicts, and refactored the conflict item UI styling in the dashboard.
- Added conflict count badge to the admin menu icon.
- Rewrote conflict messages for clarity and consistency.
- Updated conflict item component styling to WordPress-like notice style.
Reviewed Changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| inc/conflicts/wprocket.php | Updated i18n message for WP Rocket lazy load conflict. |
| inc/conflicts/jetpack_lazyload.php | Updated i18n message for Jetpack lazy load conflict. |
| inc/admin.php | Added conflict count badge logic and helper method. |
| assets/src/dashboard/parts/connected/conflicts/ConflictItem.js | Replaced severity-based background classes with styled notice box and adjusted dismissal button styling. |
Comments suppressed due to low confidence (1)
inc/conflicts/wprocket.php:1
- Translator comment lists two placeholders (1 and 2), but the string only contains %1$s and only one argument is passed. Update the comment to reflect a single placeholder (the settings link) to avoid confusing translators.
<?php
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
| /** | ||
| * Get the number of active notices (not dismissed). | ||
| * | ||
| * @return int - Number of active notices | ||
| */ | ||
| private function get_active_notices_count() { | ||
| $conflicting_plugins = $this->conflicting_plugins->get_conflicting_plugins(); | ||
|
|
||
| foreach ( $conflicting_plugins as $key => $plugin ) { | ||
| $class_name = 'Optml_' . ucfirst( $key ); | ||
|
|
||
| if ( class_exists( $class_name ) ) { | ||
| try { | ||
| $conflict_instance = new $class_name(); | ||
|
|
||
| if ( method_exists( $conflict_instance, 'is_conflict_valid' ) && ! $conflict_instance->is_conflict_valid() ) { | ||
| unset( $conflicting_plugins[ $key ] ); | ||
| } | ||
| } catch ( Exception $e ) { | ||
| unset( $conflicting_plugins[ $key ] ); | ||
| } | ||
| } | ||
| } | ||
|
|
||
| return count( $conflicting_plugins ); | ||
| } |
There was a problem hiding this comment.
We can simplify it with something like this:
<?php
/**
* Get the number of active notices (not dismissed).
*
* @return int - Number of active notices
*/
private function get_active_notices_count() {
$conflicting_plugins = $this->conflicting_plugins->get_conflicting_plugins();
$conflicts_count = 0;
foreach ( $conflicting_plugins as $key => $plugin ) {
$class_name = 'Optml_' . ucfirst( $key );
if ( ! class_exists( $class_name ) ) {
continue;
}
$conflict_instance = new $class_name();
if ( ! is_a( $conflict_instance, 'Optml_Abstract_Conflict' ) ) {
continue;
}
if ( $conflict_instance->is_conflict_valid() ) {
$conflicts_count++;
}
}
return $conflicts_count;
}945cb43 to
95ab1e0
Compare
|
🎉 This PR is included in version 4.1.0 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
All Submissions:
Changes proposed in this Pull Request:
Now, if there are any conflicts with other plugins, it will display a red label near Optimole's icon.
Closes https://github.com/Codeinwp/optimole-service/issues/1526
Other information: